home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / gfx / misc / FujiControl.lha / debugging.c < prev    next >
Encoding:
Text File  |  1999-06-05  |  1.9 KB  |  112 lines

  1. /************ testing, debugging and tracking functions ************/
  2.  
  3. printhex(char *header,char *buffer,int length)
  4. {    
  5.     int margin;
  6.     int col=0;
  7.     unsigned char a;
  8.     int i,j;
  9.  
  10.     margin=strlen(header);
  11.     printf("%s %4d:",header,length);
  12.  
  13.     for (i=0; i<length; i++)
  14.     {
  15.         if (col >= 16)
  16.         {
  17.             printf("\n");
  18.             col=0;
  19.             for(j=0; j<margin+6; j++) printf(" ");
  20.         }
  21.         printf("%02x ",a=buffer[i]);
  22.         col++;
  23.     }
  24.     if (col!=0) printf("\n");
  25.     return(1);
  26. }
  27.  
  28. printascii(char *header,char *buffer,int length)
  29. {    
  30.     int margin;
  31.     int col=0;
  32.     unsigned char a;
  33.     int i,j;
  34.  
  35.     margin=strlen(header);
  36.     printf("%s %4d:",header,length);
  37.  
  38.     for (i=0; i<length; i++)
  39.     {
  40.         if (col >= 16)
  41.         {
  42.             printf("\n");
  43.             col=0;
  44.             for(j=0; j<margin+6; j++) printf(" ");
  45.         }
  46.         a=buffer[i];
  47.         if (a<32 || a>126) a='ยค';
  48.         printf("%c  ",a);
  49.         col++;
  50.     }
  51.     if (col!=0) printf("\n");
  52.     return(1);
  53. }
  54.  
  55.  
  56. readhexchars()        /* this is a debugging function only */
  57. {
  58.     int i,numchars;
  59.     int a;
  60.     Delay(50);
  61.     numchars=readserial(buffer,MAXLEN);
  62.     printf("RX<< %4d: ",numchars);
  63.     for (i=0; i<numchars; i++)
  64.         printf("%02x ",a=buffer[i]);
  65.     printf("\n");
  66.  
  67.     return(0);
  68. }
  69.  
  70. fuji_test()
  71. {
  72.     int chars_received=0;
  73.     int i,size;
  74.     int frame,status,frames;
  75.     char filename[30];
  76.  
  77.     attention();
  78.  
  79.     set_flashmode(0);
  80.  
  81.     for(i=1; i<10 && attention(); i++)
  82.     {
  83.         charge_flash(200);
  84.         shoot(&frame,&status);
  85.         sprintf(filename,"Image%02d.jpeg\0",i+10);
  86. /*        get_image(frame,filename);*/
  87.         delete_image(frame);
  88.     }
  89.  
  90.     /* flush out the receive buffer */
  91.     printf("\n\n");
  92.     readhexchars();
  93.     printf("\n");
  94.  
  95.  
  96.  
  97.     return(1);
  98. }
  99.  
  100.  
  101.  
  102. /********************* debug bits ******************/         /*
  103. bit 0     1        Low level tracking per received and/or decoded byte
  104. bit 1     2        Print packets sent/received in hex 
  105. bit 2     4        Print packets sent/received in ascii 
  106. bit 3     8        Show acks sent/received
  107. bit 4     16        Show received headers
  108. bit 5     32        Show sent camera commands and responses
  109. bit 6      64        Show packet counter
  110. bit 7    128        Show initial contact establishment proceedings 
  111.  
  112. */